Skip to content

BUG: Refuse a read of pooled element data after its flow data closes - #292

Merged
Rakesh51D merged 1 commit into
rcfrom
fix/pooled-element-data-after-close
Nov 30, 2026
Merged

Rakesh51D merged 1 commit into
rcfrom
fix/pooled-element-data-after-close

Conversation

@Rakesh51D

Copy link
Copy Markdown
Collaborator

Element data goes back to a pool when its flow data closes, and the next request reused the same object. So a reference kept after close, such as flowdata.device stored in Flask g or read for logging after the with block, read the next visitor's results with no error. Before pooling, that read raised that the results had been closed.

What changes

  • Element data given back to a pool is closed for reading, and the pool hands the next request a copy of it rather than the same object. A kept reference raises when read, and never sees another request's values. The pool still saves making new instances.
  • Device detection and IP intelligence on-premise raise their existing "results have been closed" message, as before pooling.
  • The other pooled types (the JSON builder, the JavaScript builder, the sequence and set-headers elements, and any element on ElementDataPool) raise a new core message saying the flow data has been closed.
  • The core readme's "Element data is reused" section now says a read after close raises.

Tests

Each test keeps a reference, closes the flow data, processes a second request, and checks that the old reference raises while the new flow data reads its own values. They cover a pooled test element, the four core elements, an engine, and both on-premise packages. The tests that checked the pool returns the same object now check it returns a different one.

Cost

A process and close loop on the default pipeline, which pools all four core elements, took a median of 7,136 microseconds a request against 7,098 before, within the run-to-run spread.

Since element data started going back to a pool on close, a reference kept
after the flow data closed, for example in Flask g or for logging after the
with block, could read the next visitor's results with no error. Before
pooling, the same read raised that the results had been closed.

Element data given back to a pool is now closed for reading, and the pool
hands the next request a copy rather than the same object. So a kept
reference raises when read and never sees another request's values, and
the pool still saves making new instances. Device detection and IP
intelligence give their old results closed message, and the other pooled
types raise a new one in core saying the flow data has closed.

Tests keep a reference, close, process a second request, and check the old
reference raises while the new flow data reads its own values, for the core
elements, the engines and both on-premise packages. The core readme now
says a read after close raises.
@Rakesh51D
Rakesh51D merged commit d79e0e6 into rc Nov 30, 2026
7 checks passed
@Rakesh51D

Copy link
Copy Markdown
Collaborator Author

Merged into rc for the 4.6.2 release. In Pull Requests run 46535380851 at cae118f, every unit suite passed, including the core, engines, device detection on-premise and IP intelligence on-premise tests this change touches. The only failing check is the cloud available properties test, which fails because the CI resource key does not yet include the new ServiceWorkers property.

@Rakesh51D
Rakesh51D deleted the fix/pooled-element-data-after-close branch November 30, 2026 23:41
@Rakesh51D Rakesh51D mentioned this pull request Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant